//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package org.yaukie.base.core.bean;

import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Component
public class ApplicationContextListener implements ApplicationListener<ContextRefreshedEvent> {
    private static final Logger log = LoggerFactory.getLogger(ApplicationContextListener.class);

    public ApplicationContextListener() {
    }

    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
        if (null == contextRefreshedEvent.getApplicationContext().getParent()) {
            log.info(">>>>> spring初始化完毕 <<<<<");
            Map<String, Object> baseServices = contextRefreshedEvent.getApplicationContext().getBeansWithAnnotation(Service.class);
            Iterator var3 = baseServices.values().iterator();

            while(var3.hasNext()) {
                Object service = var3.next();
                log.info(">>>>> {}.initMapper()", service.getClass().getName());

                try {
                    Method initMapper = service.getClass().getMethod("initMapper");
                    initMapper.invoke(service);
                } catch (Exception var6) {
                    log.warn("{}缺少Mapper映射，但不影响系统运行，原因{}", service.getClass().getSimpleName(), var6.getLocalizedMessage());
                }
            }
        }

    }
}
